/**
 * \file	AbstractSyntaxTree.h
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 * \brief	Abstract Syntax Tree header.
 */

#ifndef __ABSTRACT_SYNTAX_TREE_H
#define __ABSTRACT_SYNTAX_TREE_H

#include "ASTNode.h"

/**
 * \brief	Abstract Syntax Tree (AST)
 * \details	An AST is a tree representation of the abstract syntactic structure
 *			of source code written in a programming language.
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 */
class AbstractSyntaxTree
{
private:
	/**
	 * \brief	Recursively destroy an AST structure.
	 * \param	node	AST node.
	 */
	void _destroyAST(ASTNode *node);

	/**
	 * \brief	Recursively print on console an AST structure.
	 * \param	node	AST node.
	 * \param	numTabs	number of tabulations in this level.
	 */
	void _printAST(ASTNode *node, int numTabs);

public:
	/**
	 * \brief Root node of the AST.
	 */
	ASTNode *ast;

	/**
	 * \brief	Default AbstractSyntaxTree constructor.
	 * \details	Initialize AST root node as <c>NULL</c>.
	 */
	AbstractSyntaxTree();

	/**
	 * \brief	AbstractSyntaxTree constructor.
	 * \details	Initialize AST root to a given node.
	 * \param	ast	AST root node
	 */
	AbstractSyntaxTree(ASTNode *ast);

	/**
	 * \brief	AbstractSyntaxTree destructor.
	 * \details Delete AST structure recursively starting from the root node.
	 */
	~AbstractSyntaxTree();

	/**
	 * \brief	Print on console the AST structure.
	 */
	void PrintAST();

};

#endif